﻿<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>@ViewData["Title"] - IMES工厂</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="https://unpkg.com/layui@2.8.18/dist/css/layui.css" media="all">
    <style>
        /* 全局样式重置 */
        * {
            box-sizing: border-box;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
            background-color: #f5f7fa;
        }

        /* 顶部导航栏美化 */
        .layui-layout-admin .layui-header {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            border-bottom: none;
            height: 60px;
            position: relative;
            z-index: 1000;
        }

        .layui-layout-admin .layui-header::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
            pointer-events: none;
        }

        .layui-logo {
            font-family: 'Orbitron', -apple-system, BlinkMacSystemFont, sans-serif;
            font-weight: 700;
            font-size: 20px;
            letter-spacing: 1px;
            color: #ffffff;
            text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
            position: relative;
            z-index: 1;
            display: flex;
            align-items: center;
            height: 60px;
            padding-left: 20px;
        }

        .layui-logo::before {
            content: '🏭';
            margin-right: 10px;
            font-size: 24px;
        }

        /* 用户信息区域美化 */
        .layui-nav.layui-layout-right {
            background: none;
            position: relative;
            z-index: 1;
        }

        .layui-nav.layui-layout-right .layui-nav-item {
            margin: 0;
        }

        .layui-nav.layui-layout-right .layui-nav-item>a {
            color: #ffffff;
            font-weight: 500;
            padding: 0 20px;
            height: 60px;
            line-height: 60px;
            display: flex;
            align-items: center;
            transition: all 0.3s ease;
            position: relative;
        }

        .layui-nav.layui-layout-right .layui-nav-item>a:hover {
            background: rgba(255, 255, 255, 0.1);
            color: #ffffff;
        }

        .layui-nav.layui-layout-right .layui-nav-img {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            border: 2px solid rgba(255, 255, 255, 0.3);
            margin-right: 8px;
            transition: all 0.3s ease;
        }

        .layui-nav.layui-layout-right .layui-nav-item>a:hover .layui-nav-img {
            border-color: rgba(255, 255, 255, 0.6);
            transform: scale(1.05);
        }

        /* 左侧菜单栏美化 */
        .layui-layout-admin .layui-side {
            background: linear-gradient(180deg, #2c3e50 0%, #34495e 100%);
            box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
            border-right: none;
            width: 260px;
            position: fixed;
            top: 60px;
            left: 0;
            bottom: 0;
            z-index: 999;
            overflow: hidden;
        }

        /* 主内容区域调整，避免被侧边栏遮挡 */
        .layui-layout-admin .layui-body {
            left: 260px;
            right: 0;
            /* 贴齐右侧，确保自适应宽度 */
            width: calc(100% - 260px);
            /* 明确宽度计算，避免缩放时压缩或留白 */
            background-color: #f5f7fa;
            position: relative;
            margin-top: 60px;
            overflow-y: auto;
            /* 允许内容区域滚动，避免列表被裁切 */
        }

        .layui-side-scroll {
            background: none;
            height: calc(100vh - 60px - 120px);
            /* 减去顶部导航栏高度和搜索区域高度 */
            overflow-y: auto;
            overflow-x: hidden;
        }

        /* 菜单项美化 */
        .layui-nav-tree {
            background: none;
            padding: 0;
        }

        .layui-nav-tree .layui-nav-item {
            margin: 0;
            border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        }

        .layui-nav-tree .layui-nav-item>a {
            color: #ecf0f1;
            font-weight: 500;
            padding: 15px 20px;
            height: auto;
            line-height: 1.4;
            transition: all 0.3s ease;
            position: relative;
            display: flex;
            align-items: center;
            background: none;
        }

        .layui-nav-tree .layui-nav-item>a:hover {
            background: linear-gradient(90deg, rgba(52, 152, 219, 0.2) 0%, rgba(52, 152, 219, 0.1) 100%);
            color: #ffffff;
            transform: translateX(5px);
        }

        .layui-nav-tree .layui-nav-item>a::before {
            content: '';
            position: absolute;
            left: 0;
            top: 0;
            bottom: 0;
            width: 3px;
            background: linear-gradient(180deg, #3498db, #2980b9);
            opacity: 0;
            transition: opacity 0.3s ease;
        }

        .layui-nav-tree .layui-nav-item>a:hover::before {
            opacity: 1;
        }

        .layui-nav-tree .layui-this>a {
            background: linear-gradient(90deg, rgba(52, 152, 219, 0.3) 0%, rgba(52, 152, 219, 0.1) 100%);
            color: #ffffff;
            border-left: 3px solid #3498db;
        }

        .layui-nav-tree .layui-this>a::before {
            opacity: 1;
        }

        /* 子菜单美化 */
        .layui-nav-tree .layui-nav-child {
            background: rgba(0, 0, 0, 0.1);
            border: none;
            box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
        }

        .layui-nav-tree .layui-nav-child dd {
            margin: 0;
            border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        }

        .layui-nav-tree .layui-nav-child dd:last-child {
            border-bottom: none;
        }

        .layui-nav-tree .layui-nav-child dd a {
            color: #bdc3c7;
            padding: 12px 20px 12px 40px;
            font-size: 13px;
            transition: all 0.3s ease;
            position: relative;
        }

        .layui-nav-tree .layui-nav-child dd a:hover {
            background: rgba(52, 152, 219, 0.15);
            color: #ffffff;
            transform: translateX(3px);
        }

        .layui-nav-tree .layui-nav-child dd a::before {
            content: '▶';
            position: absolute;
            left: 25px;
            color: #7f8c8d;
            font-size: 10px;
            transition: all 0.3s ease;
        }

        .layui-nav-tree .layui-nav-child dd a:hover::before {
            color: #3498db;
            transform: scale(1.2);
        }

        /* 侧边栏查询功能美化 */
        .side-search-container {
            background: linear-gradient(135deg, #34495e 0%, #2c3e50 100%);
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
            padding: 20px;
            position: relative;
            height: 120px;
            box-sizing: border-box;
        }

        .side-search-container::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: linear-gradient(135deg, rgba(52, 152, 219, 0.1) 0%, rgba(52, 152, 219, 0.05) 100%);
            pointer-events: none;
        }

        .side-search-header {
            color: #ecf0f1;
            font-size: 14px;
            font-weight: 600;
            margin-bottom: 15px;
            text-align: center;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
            padding-bottom: 10px;
            position: relative;
            z-index: 1;
        }

        .side-search-header .layui-icon {
            margin-right: 8px;
            color: #3498db;
            font-size: 16px;
        }

        .side-search-body {
            padding: 0;
            position: relative;
            z-index: 1;
        }

        .side-search-body .layui-form-item {
            margin-bottom: 0;
        }

        .side-search-body .layui-input {
            background: rgba(255, 255, 255, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.2);
            color: #ffffff;
            font-size: 13px;
            height: 36px;
            line-height: 36px;
            border-radius: 18px;
            padding: 0 15px;
            transition: all 0.3s ease;
        }

        .side-search-body .layui-input:focus {
            background: rgba(255, 255, 255, 0.15);
            border-color: #3498db;
            box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
            outline: none;
        }

        .side-search-body .layui-input::placeholder {
            color: rgba(255, 255, 255, 0.6);
            font-size: 12px;
        }

        /* 搜索下拉框美化 */
        .side-search-dropdown {
            background: rgba(44, 62, 80, 0.95);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 8px;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
            backdrop-filter: blur(10px);
        }

        .search-item {
            padding: 12px 15px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.05);
            transition: all 0.3s ease;
            border-radius: 4px;
            margin: 2px 5px;
        }

        .search-item:hover {
            background: linear-gradient(90deg, rgba(52, 152, 219, 0.2) 0%, rgba(52, 152, 219, 0.1) 100%);
            transform: translateX(3px);
        }

        .search-item.selected {
            background: linear-gradient(90deg, rgba(52, 152, 219, 0.3) 0%, rgba(52, 152, 219, 0.2) 100%);
            border-left: 3px solid #3498db;
        }

        .search-item i {
            color: #3498db;
            margin-right: 10px;
            font-size: 14px;
            width: 16px;
            text-align: center;
        }

        /* 主内容区域美化 */
        .main-content {
            padding: 20px;
            background: #ffffff;
            border-radius: 0;
            margin: 0;
            box-shadow: none;
            min-height: calc(100vh - 120px);
        }

        /* 面包屑导航美化 */
        .breadcrumb-container {
            background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
            border-bottom: 1px solid #e9ecef;
            padding: 15px 20px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
            margin: 0;
            border-radius: 0;
            position: relative;
            z-index: 10;
        }

        .breadcrumb-item {
            background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
            border: 1px solid #dee2e6;
            border-radius: 20px;
            padding: 6px 12px;
            font-size: 12px;
            font-weight: 500;
            transition: all 0.3s ease;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        }

        .breadcrumb-item:hover {
            background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
            transform: translateY(-1px);
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
        }

        .breadcrumb-item.active {
            background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
            border-color: #3498db;
            color: white;
            box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
        }

        /* 动画效果 */
        @@keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(20px);
            }

            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .layui-nav-tree .layui-nav-item {
            animation: fadeInUp 0.6s ease forwards;
        }

        .layui-nav-tree .layui-nav-item:nth-child(1) {
            animation-delay: 0.1s;
        }

        .layui-nav-tree .layui-nav-item:nth-child(2) {
            animation-delay: 0.2s;
        }

        .layui-nav-tree .layui-nav-item:nth-child(3) {
            animation-delay: 0.3s;
        }

        .layui-nav-tree .layui-nav-item:nth-child(4) {
            animation-delay: 0.4s;
        }

        .layui-nav-tree .layui-nav-item:nth-child(5) {
            animation-delay: 0.5s;
        }

        .layui-nav-tree .layui-nav-item:nth-child(6) {
            animation-delay: 0.6s;
        }

        .layui-nav-tree .layui-nav-item:nth-child(7) {
            animation-delay: 0.7s;
        }

        .layui-nav-tree .layui-nav-item:nth-child(8) {
            animation-delay: 0.8s;
        }

        .layui-nav-tree .layui-nav-item:nth-child(9) {
            animation-delay: 0.9s;
        }

        /* 响应式设计 */
        @@media (max-width: 768px) {
            .layui-layout-admin .layui-side {
                width: 200px;
            }

            .layui-layout-admin .layui-body {
                left: 200px;
            }

            .layui-logo {
                font-size: 16px;
                padding-left: 15px;
            }

            .main-content {
                padding: 15px;
            }

            .breadcrumb-container {
                padding: 10px 15px;
            }
        }

        /* 确保顶部导航栏固定 */
        .layui-layout-admin .layui-header {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            z-index: 1000;
        }

        /* 滚动条美化 */
        .layui-side-scroll::-webkit-scrollbar {
            width: 6px;
        }

        .layui-side-scroll::-webkit-scrollbar-track {
            background: rgba(255, 255, 255, 0.1);
            border-radius: 3px;
        }

        .layui-side-scroll::-webkit-scrollbar-thumb {
            background: rgba(52, 152, 219, 0.5);
            border-radius: 3px;
        }

        .layui-side-scroll::-webkit-scrollbar-thumb:hover {
            background: rgba(52, 152, 219, 0.7);
        }

        /* 保持原有的其他样式 */
        .welcome-info {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 20px;
            border-radius: 8px;
            margin-bottom: 20px;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
        }

        .layui-footer {
            background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
            color: #ecf0f1;
            text-align: center;
            padding: 15px;
            font-weight: 500;
        }

        /* 面包屑导航样式补充 */
        .breadcrumb-wrapper {
            display: flex;
            align-items: center;
            flex-wrap: wrap;
            gap: 8px;
        }

        /* 删除面包屑导航中的斜杠 */
        .breadcrumb-item+.breadcrumb-item::before {
            display: none !important;
        }

        .breadcrumb-item {
            display: inline-flex;
            align-items: center;
            cursor: pointer;
            position: relative;
        }

        .breadcrumb-item .close-btn {
            margin-left: 8px;
            width: 16px;
            height: 16px;
            line-height: 16px;
            text-align: center;
            border-radius: 50%;
            background-color: rgba(255, 255, 255, 0.2);
            color: inherit;
            font-size: 10px;
            cursor: pointer;
            display: none;
            transition: all 0.3s ease;
        }

        .breadcrumb-item:not(.active):hover .close-btn {
            display: inline-block;
        }

        .breadcrumb-item .close-btn:hover {
            background-color: rgba(255, 255, 255, 0.3);
            transform: scale(1.1);
        }

        .breadcrumb-item.active .close-btn {
            background-color: rgba(255, 255, 255, 0.2);
            color: white;
            display: inline-block;
        }

        .breadcrumb-item.active .close-btn:hover {
            background-color: rgba(255, 255, 255, 0.3);
        }

        /* 首页面包屑的关闭按钮始终显示 */
        .breadcrumb-item[data-path="/Home/Index"] .close-btn {
            display: inline-block !important;
        }

        /* 确保下拉菜单正常工作 */
        .layui-nav-tree .layui-nav-child {
            display: none;
        }

        .layui-nav-tree .layui-nav-itemed>.layui-nav-child {
            display: block;
        }
    </style>
    @await RenderSectionAsync("Styles", required: false)
    <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
    <link rel="stylesheet" href="~/css/custom.css" />
</head>

<body class="layui-layout-body">
    <div class="layui-layout layui-layout-admin">
        <div class="layui-header">
            <div class="layui-logo">IMES工厂</div>
            <ul class="layui-nav layui-layout-right">
                <li class="layui-nav-item">
                    <a href="javascript:;">
                        <img src="//tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg"
                            class="layui-nav-img">
                        @Context.Session.GetString("UserName")
                    </a>
                    <dl class="layui-nav-child">
                        <dd><a href="/">退出登录</a></dd>
                    </dl>
                </li>
            </ul>
        </div>

        <div class="layui-side layui-bg-black">
            <!-- 查询菜单功能 -->
            <div class="side-search-container">
                <div class="side-search-header">
                    <i class="layui-icon layui-icon-search"></i> 快速查询
                </div>
                <div class="side-search-body">
                    <form class="layui-form" id="sideSearchForm">
                        <div class="layui-form-item">
                            <input type="text" id="sideSearchInput" placeholder="输入关键词搜索..." autocomplete="off"
                                class="layui-input">
                            <div id="sideSearchDropdown" class="side-search-dropdown" style="display: none;">
                                <div class="search-item" data-value="home" data-text="首页">
                                    <i class="layui-icon layui-icon-home"></i>
                                    <span>首页</span>
                                </div>
                                <div class="search-item" data-value="system" data-text="系统管理">
                                    <i class="layui-icon layui-icon-set"></i>
                                    <span>系统管理</span>
                                </div>
                                <div class="search-item" data-value="user" data-text="用户管理">
                                    <i class="layui-icon layui-icon-user"></i>
                                    <span>用户管理</span>
                                </div>
                                <div class="search-item" data-value="role" data-text="角色管理">
                                    <i class="layui-icon layui-icon-group"></i>
                                    <span>角色管理</span>
                                </div>
                                <div class="search-item" data-value="permission" data-text="权限管理">
                                    <i class="layui-icon layui-icon-set"></i>
                                    <span>权限管理</span>
                                </div>
                                <div class="search-item" data-value="route" data-text="工艺路线管理">
                                    <i class="layui-icon layui-icon-template"></i>
                                    <span>工艺路线管理</span>
                                </div>
                                <div class="search-item" data-value="process" data-text="工艺路线">
                                    <i class="layui-icon layui-icon-template-1"></i>
                                    <span>工艺路线</span>
                                </div>
                                <div class="search-item" data-value="processmanage" data-text="工序管理">
                                    <i class="layui-icon layui-icon-cogs"></i>
                                    <span>工序管理</span>
                                </div>
                                <div class="search-item" data-value="worktask" data-text="任务管理">
                                    <i class="layui-icon layui-icon-list"></i>
                                    <span>任务管理</span>
                                </div>
                                <div class="search-item" data-value="production" data-text="生产管理">
                                    <i class="layui-icon layui-icon-set"></i>
                                    <span>生产管理</span>
                                </div>
                                <div class="search-item" data-value="workreport" data-text="报工">
                                    <i class="layui-icon layui-icon-chart"></i>
                                    <span>报工</span>
                                </div>
                                <div class="search-item" data-value="completionsheet" data-text="完工单">
                                    <i class="layui-icon layui-icon-file"></i>
                                    <span>完工单</span>
                                </div>
                                <div class="search-item" data-value="productionreport" data-text="生产报表">
                                    <i class="layui-icon layui-icon-chart-screen"></i>
                                    <span>生产报表</span>
                                </div>
                                <div class="search-item" data-value="defective" data-text="不良品管理">
                                    <i class="layui-icon layui-icon-close"></i>
                                    <span>不良品管理</span>
                                </div>
                                <div class="search-item" data-value="defectivesummary" data-text="不良品汇总">
                                    <i class="layui-icon layui-icon-chart-screen"></i>
                                    <span>不良品汇总</span>
                                </div>
                                <div class="search-item" data-value="defectiveitem" data-text="不良品项分布">
                                    <i class="layui-icon layui-icon-chart"></i>
                                    <span>不良品项分布</span>
                                </div>
                                <div class="search-item" data-value="inventory" data-text="库存管理">
                                    <i class="layui-icon layui-icon-component"></i>
                                    <span>库存管理</span>
                                </div>
                                <div class="search-item" data-value="balance" data-text="库存余额">
                                    <i class="layui-icon layui-icon-form"></i>
                                    <span>库存余额</span>
                                </div>
                                <div class="search-item" data-value="warehousing" data-text="入库单">
                                    <i class="layui-icon layui-icon-tabs"></i>
                                    <span>入库单</span>
                                </div>
                                <div class="search-item" data-value="outbound" data-text="出库单">
                                    <i class="layui-icon layui-icon-tabs"></i>
                                    <span>出库单</span>
                                </div>
                                <div class="search-item" data-value="details" data-text="库存收发明细">
                                    <i class="layui-icon layui-icon-tabs"></i>
                                    <span>库存收发明细</span>
                                </div>
                                <div class="search-item" data-value="salesorder" data-text="销售订单">
                                    <i class="layui-icon layui-icon-cart"></i>
                                    <span>销售订单</span>
                                </div>
                                <div class="search-item" data-value="team" data-text="班组管理">
                                    <i class="layui-icon layui-icon-group"></i>
                                    <span>班组管理</span>
                                </div>

                                <div class="search-item" data-value="plan" data-text="生产计划管理">
                                    <i class="layui-icon layui-icon-calendar"></i>
                                    <span>生产计划管理</span>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>

            <div class="layui-side-scroll">
                <ul class="layui-nav layui-nav-tree">
                    <li class="layui-nav-item">
                        <a href="@Url.Action("Index", "Home")">首页</a>
                    </li>
                    <li class="layui-nav-item">
                        <a href="javascript:;">系统管理</a>
                        <dl class="layui-nav-child">
                            <dd><a href="@Url.Action("UserManagement", "Account")">用户管理</a></dd>
                            <dd><a href="@Url.Action("RoleManagement", "Role")">角色管理</a></dd>
                            <dd><a href="@Url.Action("PermissionManagement", "Permission")">权限管理</a></dd>
                        </dl>
                    </li>
                    <li class="layui-nav-item layui-nav-itemed">
                        <a href="javascript:;">工艺路线管理</a>
                        <dl class="layui-nav-child">
                            <dd><a href="@Url.Action("Index", "Route")">工艺路线</a></dd>
                            <dd><a href="@Url.Action("Index", "Process")">工序管理</a></dd>
                            <dd><a href="@Url.Action("Index", "WorkTask")">任务管理</a></dd>
                        </dl>
                    </li>
                    <li class="layui-nav-item">
                        <a href="javascript:;">生产管理</a>
                        <dl class="layui-nav-child">
                            <dd><a href="@Url.Action("Index", "SalesOrder")">销售订单</a></dd>
                            <dd><a href="@Url.Action("Index", "WorkOrder")">工单管理</a></dd>
                            <dd><a href="@Url.Action("Index", "WorkReport")">报工</a></dd>
                            <dd><a href="@Url.Action("CompletionSheet", "Production")">完工单</a></dd>
                            <dd><a href="@Url.Action("ProductionReport", "Production")">生产报表</a></dd>
                        </dl>
                    </li>
                    <li class="layui-nav-item">
                        <a href="javascript:;">不良品管理</a>
                        <dl class="layui-nav-child">
                            <dd><a href="@Url.Action("Index", "Defective")">不良品管理</a></dd>
                            <dd><a href="@Url.Action("Index", "DefectiveSummary")">不良品汇总</a></dd>
                            <dd><a href="@Url.Action("Index", "DefectiveItemDistribution")">不良品项分布</a></dd>
                        </dl>
                    </li>
                    <li class="layui-nav-item">
                        <a href="javascript:;">库存管理</a>
                        <dl class="layui-nav-child">
                            <dd><a href="@Url.Action("Balance", "Inventory")">库存余额</a></dd>
                            <dd><a href="@Url.Action("Warehousing", "Inventory")">入库单</a></dd>
                            <dd><a href="@Url.Action("Outbound", "Inventory")">出库单</a></dd>
                            <dd><a href="@Url.Action("Details", "Inventory")">库存收发明细</a></dd>
                        </dl>
                    </li>
                    <li class="layui-nav-item">
                        <a href="@Url.Action("Index", "Team")">班组管理</a>
                    </li>
                    <li class="layui-nav-item">
                        <a href="@Url.Action("Index", "Plan")">生产计划管理</a>
                    </li>
                </ul>
            </div>
        </div>

        <div class="layui-body">
            <!-- 面包屑导航 -->
            <div class="breadcrumb-container">
                <div class="breadcrumb-wrapper">
                    <span class="breadcrumb-item active" data-path="/Home/Index" data-title="首页">首页</span>
                </div>
            </div>

            <div class="main-content">
                @RenderBody()
            </div>
        </div>

        <div class="layui-footer">
            © 2024 IMES工厂
        </div>
    </div>

    <script src="~/lib/jquery/dist/jquery.min.js"></script>
    <script src="https://unpkg.com/layui@2.8.18/dist/layui.js"></script>
    <script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
    <script>
        layui.use(['element', 'table', 'form', 'layer', 'laypage'], function () {
            var element = layui.element;
            var table = layui.table;
            var form = layui.form;
            var layer = layui.layer;
            var laypage = layui.laypage;
            var $ = layui.$ || window.jQuery;

            // 重新渲染导航菜单，确保下拉菜单正常工作
            element.render('nav');


            // 侧边栏可搜索下拉框功能
            var searchInput = $('#sideSearchInput');
            var searchDropdown = $('#sideSearchDropdown');
            var searchItems = $('.search-item');
            var selectedIndex = -1;

            // 搜索输入框事件
            searchInput.on('input', function () {
                var keyword = $(this).val().toLowerCase();
                filterSearchItems(keyword);
            });

            // 搜索输入框焦点事件
            searchInput.on('focus', function () {
                searchDropdown.show();
                searchItems.show();
            });

            // 搜索输入框点击事件
            searchInput.on('click', function () {
                searchDropdown.show();
                searchItems.show();
            });

            // 搜索输入框失焦事件
            searchInput.on('blur', function () {
                setTimeout(function () {
                    searchDropdown.hide();
                    selectedIndex = -1;
                }, 300);
            });

            // 键盘导航
            searchInput.on('keydown', function (e) {
                var visibleItems = $('.search-item:visible');

                switch (e.keyCode) {
                    case 40: // 下箭头
                        e.preventDefault();
                        selectedIndex = Math.min(selectedIndex + 1, visibleItems.length - 1);
                        updateSelection(visibleItems);
                        break;
                    case 38: // 上箭头
                        e.preventDefault();
                        selectedIndex = Math.max(selectedIndex - 1, -1);
                        updateSelection(visibleItems);
                        break;
                    case 13: // 回车
                        e.preventDefault();
                        if (selectedIndex >= 0) {
                            var selectedItem = visibleItems.eq(selectedIndex);
                            selectSearchItem(selectedItem);
                        }
                        break;
                    case 27: // ESC
                        searchDropdown.hide();
                        selectedIndex = -1;
                        break;
                }
            });

            // 点击搜索项
            searchItems.on('click', function () {
                selectSearchItem($(this));
            });

            // 过滤搜索项
            function filterSearchItems(keyword) {
                if (!keyword) {
                    searchItems.show();
                    searchDropdown.show();
                    return;
                }

                var hasVisibleItems = false;
                searchItems.each(function () {
                    var item = $(this);
                    var text = item.attr('data-text').toLowerCase();

                    if (text.includes(keyword)) {
                        item.show();
                        hasVisibleItems = true;
                    } else {
                        item.hide();
                    }
                });

                if (hasVisibleItems) {
                    searchDropdown.show();
                } else {
                    searchDropdown.hide();
                }

                selectedIndex = -1;
            }

            // 更新选择状态
            function updateSelection(visibleItems) {
                visibleItems.removeClass('selected');
                if (selectedIndex >= 0) {
                    visibleItems.eq(selectedIndex).addClass('selected');
                }
            }

            // 选择搜索项
            function selectSearchItem(item) {
                var value = item.attr('data-value');
                var text = item.attr('data-text');

                searchInput.val(text);
                searchDropdown.hide();
                selectedIndex = -1;

                // 跳转到对应页面
                handleSideSearch(value);
            }

            // 处理侧边栏查询
            function handleSideSearch(searchType) {
                // 根据查询类型跳转到相应页面，与导航菜单路由保持一致
                var urls = {
                    'home': '@Url.Action("Index", "Home")',
                    'system': '@Url.Action("UserManagement", "Account")', // 系统管理默认跳转到用户管理
                    'user': '@Url.Action("UserManagement", "Account")',
                    'role': '@Url.Action("RoleManagement", "Role")',
                    'permission': '@Url.Action("PermissionManagement", "Permission")',
                    'route': '@Url.Action("Index", "Route")',
                    'process': '@Url.Action("Index", "Route")',
                    'processmanage': '@Url.Action("Index", "Process")',
                    'worktask': '@Url.Action("Index", "WorkTask")',
                    'salesorder': '@Url.Action("Index", "SalesOrder")',
                    'production': '@Url.Action("Index", "WorkReport")',
                    'workreport': '@Url.Action("Index", "WorkReport")',
                    'completionsheet': '@Url.Action("CompletionSheet", "Production")',
                    'productionreport': '@Url.Action("ProductionReport", "Production")',
                    'defective': '@Url.Action("Index", "Defective")',
                    'defectivesummary': '@Url.Action("Index", "DefectiveSummary")',
                    'defectiveitem': '@Url.Action("Index", "DefectiveItemDistribution")',
                    'team': '@Url.Action("Index", "Team")',
                    'kanban': '@Url.Action("Index", "Kanban")',
                    'plan': '@Url.Action("Index", "Plan")',
                    'inventory': '@Url.Action("Balance", "Inventory")',
                    'balance': '@Url.Action("Balance", "Inventory")',
                    'warehousing': '@Url.Action("Warehousing", "Inventory")',
                    'outbound': '@Url.Action("Outbound", "Inventory")',
                    'details': '@Url.Action("Details", "Inventory")'
                };

                var titles = {
                    'home': '首页',
                    'system': '系统管理',
                    'user': '用户管理',
                    'role': '角色管理',
                    'permission': '权限管理',
                    'route': '工艺路线管理',
                    'process': '工艺路线',
                    'processmanage': '工序管理',
                    'worktask': '任务管理',
                    'salesorder': '销售订单',
                    'production': '生产管理',
                    'workreport': '报工',
                    'completionsheet': '完工单',
                    'productionreport': '生产报表',
                    'defective': '不良品管理',
                    'defectivesummary': '不良品汇总',
                    'defectiveitem': '不良品项分布',
                    'team': '班组管理',
                    'kanban': '看板管理',
                    'plan': '生产计划管理',
                    'inventory': '库存管理',
                    'balance': '库存余额',
                    'warehousing': '入库单',
                    'outbound': '出库单',
                    'details': '库存收发明细'
                };

                var url = urls[searchType];
                var title = titles[searchType];

                if (url) {
                    // 添加面包屑
                    addBreadcrumb(title, url);
                    // 直接跳转到对应页面
                    window.location.href = url;
                }
            }

            // 页面加载时设置当前页面对应的搜索框内容
            function setCurrentPageSearchText() {
                var currentPath = window.location.pathname;
                var searchText = '';

                // 根据当前路径设置对应的搜索文本
                if (currentPath.includes('/Home/Index') || currentPath === '/') {
                    searchText = '首页';
                } else if (currentPath.includes('/Account/UserManagement') ||
                    currentPath.includes('/Role/RoleManagement') ||
                    currentPath.includes('/Permission/PermissionManagement')) {
                    searchText = '系统管理';
                } else if (currentPath.includes('/Route/Index')) {
                    searchText = '工艺路线';
                } else if (currentPath.includes('/Process/Index')) {
                    searchText = '工序管理';
                } else if (currentPath.includes('/WorkTask/Index')) {
                    searchText = '任务管理';
                } else if (currentPath.includes('/SalesOrder/Index')) {
                    searchText = '销售订单';
                } else if (currentPath.includes('/WorkOrder/Index')) {
                    searchText = '工单管理';
                } else if (currentPath.includes('/WorkReport/Index')) {
                    searchText = '报工';
                } else if (currentPath.includes('/Production/CompletionSheet')) {
                    searchText = '完工单';
                } else if (currentPath.includes('/Production/ProductionReport')) {
                    searchText = '生产报表';
                } else if (currentPath.includes('/Defective/Index')) {
                    searchText = '不良品管理';
                } else if (currentPath.includes('/DefectiveSummary/Index')) {
                    searchText = '不良品汇总';
                } else if (currentPath.includes('/DefectiveItemDistribution/Index')) {
                    searchText = '不良品项分布';
                } else if (currentPath.includes('/Team/Index')) {
                    searchText = '班组管理';
                } else if (currentPath.includes('/Inventory/Balance')) {
                    searchText = '库存余额';
                } else if (currentPath.includes('/Inventory/Outbound')) {
                    searchText = '出库单';
                } else if (currentPath.includes('/Inventory/Details')) {
                    searchText = '库存收发明细';
                } else if (currentPath.includes('/Inventory/Warehousing')) {
                    searchText = '入库单';
                } else if (currentPath.includes('/Plan/Index')) {
                    searchText = '生产计划管理';
                }

                // 设置搜索框的值
                searchInput.val(searchText);

            }

            // 面包屑导航功能
            var breadcrumbWrapper = $('.breadcrumb-wrapper');
            var currentBreadcrumb = null;

            // 初始化面包屑导航
            function initBreadcrumb() {
                // 尝试从localStorage恢复面包屑
                var restored = loadBreadcrumbsFromStorage();

                if (!restored) {
                    // 如果没有保存的面包屑，创建默认的首页面包屑
                    breadcrumbWrapper.empty();
                    addBreadcrumb('首页', '/Home/Index');
                } else {
                    // 确保首页面包屑始终存在
                    var homeBreadcrumb = breadcrumbWrapper.find('.breadcrumb-item[data-path="/Home/Index"]');
                    if (homeBreadcrumb.length === 0) {
                        // 在开头插入首页面包屑
                        var homeHtml = '<span class="breadcrumb-item" data-path="/Home/Index" data-title="首页">首页<span class="close-btn" title="关闭">×</span></span>';
                        var homeElement = $(homeHtml);
                        breadcrumbWrapper.prepend(homeElement);
                        bindBreadcrumbEvents(homeElement);
                    }
                }

                // 根据当前路径设置活动状态
                setActiveBreadcrumb();
            }

            // 添加面包屑
            function addBreadcrumb(title, path) {
                // 检查是否已存在
                var existingBreadcrumb = breadcrumbWrapper.find('.breadcrumb-item[data-path="' + path + '"]');
                if (existingBreadcrumb.length > 0) {
                    setActiveBreadcrumbItem(existingBreadcrumb);
                    return;
                }

                // 创建新的面包屑项
                var breadcrumbHtml = '<span class="breadcrumb-item" data-path="' + path + '" data-title="' + title + '">' +
                    title +
                    '<span class="close-btn" title="关闭">×</span>' +
                    '</span>';

                var newBreadcrumb = $(breadcrumbHtml);
                breadcrumbWrapper.append(newBreadcrumb);

                // 绑定事件
                bindBreadcrumbEvents(newBreadcrumb);

                // 设置为活动状态
                setActiveBreadcrumbItem(newBreadcrumb);

                // 保存到localStorage
                saveBreadcrumbsToStorage();
            }

            // 绑定面包屑事件
            function bindBreadcrumbEvents(breadcrumbItem) {
                // 点击面包屑项
                breadcrumbItem.on('click', function (e) {
                    if (!$(e.target).hasClass('close-btn')) {
                        var path = $(this).attr('data-path');
                        if (path) {
                            // 设置当前面包屑为活动状态
                            setActiveBreadcrumbItem($(this));
                            // 跳转到对应页面
                            if (path !== window.location.pathname) {
                                window.location.href = path;
                            }
                        }
                    }
                });

                // 双击面包屑项跳转到首页
                breadcrumbItem.on('dblclick', function (e) {
                    if (!$(e.target).hasClass('close-btn')) {
                        window.location.href = '/Home/Index';
                    }
                });

                // 点击关闭按钮
                breadcrumbItem.find('.close-btn').on('click', function (e) {
                    e.stopPropagation();
                    var breadcrumb = $(this).parent();
                    var isActive = breadcrumb.hasClass('active');
                    var isHome = breadcrumb.attr('data-path') === '/Home/Index';

                    // 移除面包屑
                    breadcrumb.remove();

                    // 保存到localStorage
                    saveBreadcrumbsToStorage();

                    // 如果删除的是活动状态的面包屑，需要跳转到其他页面
                    if (isActive) {
                        var nextBreadcrumb = breadcrumb.next('.breadcrumb-item');
                        var prevBreadcrumb = breadcrumb.prev('.breadcrumb-item');

                        if (nextBreadcrumb.length > 0) {
                            // 跳转到下一个面包屑对应的页面
                            var nextPath = nextBreadcrumb.attr('data-path');
                            if (nextPath) {
                                window.location.href = nextPath;
                            }
                        } else if (prevBreadcrumb.length > 0) {
                            // 跳转到上一个面包屑对应的页面
                            var prevPath = prevBreadcrumb.attr('data-path');
                            if (prevPath) {
                                window.location.href = prevPath;
                            }
                        } else {
                            // 如果没有其他面包屑，跳转到首页
                            window.location.href = '/Home/Index';
                        }
                    } else if (isHome) {
                        // 如果删除的是首页面包屑，跳转到首页
                        window.location.href = '/Home/Index';
                    }
                });
            }

            // 设置活动面包屑
            function setActiveBreadcrumbItem(breadcrumbItem) {
                breadcrumbWrapper.find('.breadcrumb-item').removeClass('active');
                breadcrumbItem.addClass('active');
                currentBreadcrumb = breadcrumbItem;
            }

            // 根据当前路径设置活动面包屑
            function setActiveBreadcrumb() {
                var currentPath = window.location.pathname;
                var targetBreadcrumb = breadcrumbWrapper.find('.breadcrumb-item[data-path="' + currentPath + '"]');

                if (targetBreadcrumb.length > 0) {
                    setActiveBreadcrumbItem(targetBreadcrumb);
                } else {
                    // 如果当前路径没有对应的面包屑，添加一个
                    var pageTitle = getPageTitle(currentPath);
                    if (pageTitle) {
                        addBreadcrumb(pageTitle, currentPath);
                    }
                }
            }

            // 根据路径获取页面标题
            function getPageTitle(path) {
                var titleMap = {
                    '/Home/Index': '首页',
                    '/Account/UserManagement': '用户管理',
                    '/Role/RoleManagement': '角色管理',
                    '/Permission/PermissionManagement': '权限管理',
                    '/Route/Index': '工艺路线',
                    '/Process/Index': '工序管理',
                    '/WorkTask/Index': '任务管理',
                    '/SalesOrder/Index': '销售订单',
                    '/WorkOrder/Index': '工单管理',
                    '/WorkReport/Index': '报工',
                    '/Production/CompletionSheet': '完工单',
                    '/Production/ProductionReport': '生产报表',
                    '/Defective/Index': '不良品管理',
                    '/DefectiveSummary/Index': '不良品汇总',
                    '/DefectiveItemDistribution/Index': '不良品项分布',
                    '/Team/Index': '班组管理',
                    '/Kanban/Index': '看板管理',
                    '/Inventory/Balance': '库存余额',
                    '/Inventory/Warehousing': '入库单',
                    '/Inventory/Outbound': '出库单',
                    '/Inventory/Details': '库存收发明细',
                    '/Plan/Index': '生产计划管理'
                };

                return titleMap[path] || '未知页面';
            }

            // 保存面包屑到localStorage
            function saveBreadcrumbsToStorage() {
                var breadcrumbs = [];
                breadcrumbWrapper.find('.breadcrumb-item').each(function () {
                    breadcrumbs.push({
                        title: $(this).attr('data-title'),
                        path: $(this).attr('data-path'),
                        active: $(this).hasClass('active')
                    });
                });
                localStorage.setItem('breadcrumbs', JSON.stringify(breadcrumbs));
            }

            // 从localStorage恢复面包屑
            function loadBreadcrumbsFromStorage() {
                var savedBreadcrumbs = localStorage.getItem('breadcrumbs');
                if (savedBreadcrumbs) {
                    try {
                        var breadcrumbs = JSON.parse(savedBreadcrumbs);
                        breadcrumbWrapper.empty();

                        breadcrumbs.forEach(function (item) {
                            var breadcrumbHtml = '<span class="breadcrumb-item' + (item.active ? ' active' : '') + '" data-path="' + item.path + '" data-title="' + item.title + '">' +
                                item.title +
                                '<span class="close-btn" title="关闭">×</span>' +
                                '</span>';

                            var breadcrumb = $(breadcrumbHtml);
                            breadcrumbWrapper.append(breadcrumb);
                            bindBreadcrumbEvents(breadcrumb);
                        });

                        return true;
                    } catch (e) {
                        console.error('恢复面包屑失败:', e);
                    }
                }
                return false;
            }

            // 为导航菜单添加面包屑功能
            $('.layui-nav-tree a').on('click', function () {
                var href = $(this).attr('href');
                var title = $(this).text().trim();

                if (href && href !== 'javascript:;' && href !== '#') {
                    // 立即添加面包屑，不等待页面跳转
                    addBreadcrumb(title, href);
                }
            });

            // 页面加载完成后执行
            $(document).ready(function () {
                setCurrentPageSearchText();
                initBreadcrumb();

                // 为现有的面包屑绑定事件
                breadcrumbWrapper.find('.breadcrumb-item').each(function () {
                    bindBreadcrumbEvents($(this));
                });

                // 设置当前页面对应的导航菜单活动状态
                setActiveNavItem();
            });

            // 设置当前页面对应的导航菜单活动状态
            function setActiveNavItem() {
                var currentPath = window.location.pathname;

                // 移除所有活动状态
                $('.layui-nav-tree .layui-nav-item').removeClass('layui-nav-itemed layui-this');

                // 根据当前路径设置活动状态
                if (currentPath.includes('/Account/UserManagement') ||
                    currentPath.includes('/Role/RoleManagement') ||
                    currentPath.includes('/Permission/PermissionManagement')) {
                    // 系统管理菜单项
                    $('.layui-nav-tree .layui-nav-item').eq(1).addClass('layui-nav-itemed');
                } else if (currentPath.includes('/Route/Index') ||
                    currentPath.includes('/Process/Index') ||
                    currentPath.includes('/WorkTask/Index')) {
                    // 工艺路线管理菜单项
                    $('.layui-nav-tree .layui-nav-item').eq(2).addClass('layui-nav-itemed');
                } else if (currentPath.includes('/SalesOrder/Index') ||
                    currentPath.includes('/WorkOrder/Index') ||
                    currentPath.includes('/WorkReport/Index') ||
                    currentPath.includes('/Production/CompletionSheet') ||
                    currentPath.includes('/Production/ProductionReport')) {
                    // 生产管理菜单项
                    $('.layui-nav-tree .layui-nav-item').eq(3).addClass('layui-nav-itemed');
                } else if (currentPath.includes('/Defective/Index') ||
                    currentPath.includes('/DefectiveSummary/Index') ||
                    currentPath.includes('/DefectiveItemDistribution/Index')) {
                    // 不良品管理菜单项
                    $('.layui-nav-tree .layui-nav-item').eq(4).addClass('layui-nav-itemed');
                } else if (currentPath.includes('/Inventory/Balance') ||
                    currentPath.includes('/Inventory/Outbound') ||
                    currentPath.includes('/Inventory/Details') ||
                    currentPath.includes('/Inventory/Warehousing')) {
                    // 库存管理菜单项
                    $('.layui-nav-tree .layui-nav-item').eq(5).addClass('layui-nav-itemed');
                } else if (currentPath.includes('/Team/Index')) {
                    // 班组管理菜单项
                    $('.layui-nav-tree .layui-nav-item').eq(6).addClass('layui-this');
                } else if (currentPath.includes('/Plan/Index')) {
                    // 生产计划管理菜单项
                    $('.layui-nav-tree .layui-nav-item').eq(7).addClass('layui-this');
                } else if (currentPath.includes('/Home/Index') || currentPath === '/') {
                    // 首页菜单项
                    $('.layui-nav-tree .layui-nav-item').eq(0).addClass('layui-this');
                }
            }

            // 侧边栏快捷键支持
            $(document).keydown(function (e) {
                // Ctrl + Shift + F 聚焦到侧边栏关键词输入框
                if (e.ctrlKey && e.shiftKey && e.keyCode === 70) {
                    e.preventDefault();
                    $('#sideSearchInput').focus();
                }
            });

        });
    </script>
    @await RenderSectionAsync("Scripts", required: false)
</body>

</html>
